package com.zbest.zpay.acctrans.common.util;

import org.apache.commons.lang.StringUtils;

import com.zbest.common.lang.base.Money;
import com.zbest.zpay.acctrans.common.exception.AccTransRuntimeException;

public class BalanceTagUtils {

	public static String createBalanceTag(String actNo, Money bal)
			throws AccTransRuntimeException {
		String amt = Long.toString(bal.getCent());
		CryptUtils crp = new CryptUtils();
		String cryptSeed = actNo + amt;
		return crp.cryptMd5(cryptSeed, "duodian8");
	}

	public static boolean verifyBalanceTag(String actNo,
			Money bal, String oldBalTag) throws AccTransRuntimeException {
		String amt = Long.toString(bal.getCent());
		CryptUtils crp = new CryptUtils();
		String cryptSeed = actNo + amt;
		String newBalTag = crp.cryptMd5(cryptSeed, "duodian8");
		boolean flag = false;
		if (StringUtils.equalsIgnoreCase(newBalTag, oldBalTag)) {
			flag = true;
		}
		return flag;
	}

}
